package com.smart.car.gateway.controller;

import com.smart.car.common.res.bean.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO 网关熔断降级测试
 *
 * @author zoutao.blog.csdn.net
 * @date 2021/5/31
 */
@Slf4j
@RestController
@RequestMapping("error")
public class FallbackController {

    //多组请求get、post通用
    @RequestMapping("/fallback")
    public ResponseResult<String> fallback() {
        ResponseResult<String> result = new ResponseResult<>();
        log.error("调用网关中的服务失败...");
        result.setCode(429);
        //真实业务下一般是："xxx服务繁忙，请稍后重试";
        result.setMsg("对应的服务调用失败，快速熔断，进入fallback降级方法。");
        return result;
    }
}
